#!/usr/bin/python
# -*- coding: utf-8 -*-
"""docstrings
"""

from google.appengine.ext import db

class Model(db.Model):
    
    def to_dict(self):
        d = {'key': str(self.key())}
        for k in self.properties():
            v = getattr(self, k)
            if v is not None:
                d[k] = getattr(self, k)
        return d

    def save(self, data=None):
        if data is not None:
            for k in self.properties():
                if k in data:
                    setattr(self, k, data[k])
        super(Model, self).save()